#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

void solve() {
    int n, m;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    vector<pair<int, int>> d(m);
    for (int i = 0; i < m; i++) cin >> d[i].first >> d[i].second;
    int minn = INT_MAX;
    for (int b = 1; b < (1 << n); b++) {
        int sum = 0;
        int min_val = INT_MAX;
        for (int i = 0; i < n; i++) {
            if (b & (1 << i)) {
                sum += a[i];
                if (a[i] < min_val) min_val = a[i];
            }
        }
        bool f = true;
        for (int i = 0; i < m; i++) {
            int t = d[i].first;
            int x = d[i].second;
            if (t == 1) {
                if (sum < x) {
                    f = false;
                    break;
                }
            } else {
                if (min_val > x) {
                    f = false;
                    break;
                }
            }
        }
        if (f) {
            int cnt = __builtin_popcount(b);
            if (cnt < minn) minn = cnt;
        }
    }
    if (minn == INT_MAX) {
        cout << "-1" << endl;
    } else {
        cout << minn << endl;
    }

    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}